package com.kou.service.impl;

import com.kou.dao.TypeDao;
import com.kou.dao.TypeDaoImpl;
import com.kou.pojo.Type;
import com.kou.service.TypeService;

import java.util.List;

/**
 * @author SteinY
 * @create 2022-03-25 11:20
 * @description:
 */
public class TypeServiceImpl implements TypeService {
    TypeDao typeDao = new TypeDaoImpl();
    @Override
    public List<Type> findAll() {
        return typeDao.findAll();

    }

    @Override
    public List<Type> select(String level, String goodsname) {
        return typeDao.select(level,goodsname);
    }

    @Override
    public List<Type> findSon(String id) {
        return typeDao.findSon(id);
    }

    @Override
    public void delete(String id) {
        try {
            typeDao.delete(id);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
    }

    @Override
    public void create(String goodsParent, String typename) {
        int level = typeDao.findLevel(Integer.parseInt(goodsParent));
        typeDao.create(Integer.parseInt(goodsParent),level+1,typename);
    }

    @Override
    public List<Type> findAll1() {
        return typeDao.findAll1();
    }

    @Override
    public Type find(int id) {
        return typeDao.find(id);
    }

    @Override
    public void update(Type type) {
        typeDao.update(type);
    }
}
